package com.hrms.web.sys_role_menu.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hrms.web.sys_role_menu.entity.SaveMenuParm;
import com.hrms.web.sys_role_menu.entity.SysRoleMenu;
import com.hrms.web.sys_role_menu.mapper.SysRoleMenuMapper;
import com.hrms.web.sys_role_menu.service.SysRoleMenuService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Title: SysRoleMenuServiceImpl
 * @Author zhanji
 * @Package com.hrms.web.sys_role_menu.service.impl
 * @description:
 */
@Service
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements SysRoleMenuService {
    @Override
    @Transactional
    public void saveRoleMenu(SaveMenuParm saveMenuParm) {
        //先删除原先数据
        QueryWrapper<SysRoleMenu> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(SysRoleMenu::getRoleId,saveMenuParm.getRoleId());
        this.baseMapper.delete(queryWrapper);
        //再保存新数据
        this.baseMapper.saveRoleMenu(saveMenuParm.getRoleId(),saveMenuParm.getList());
    }
}
